package me.date.a01datedemo1;

import java.util.Date;
import java.util.Random;

public class DateDemo2 {
    public static void main(String[] args) {
        //extracted();
        //比较时间
        Random r = new Random();
        Date d1 = new Date(Math.abs(r.nextInt()));
        Date d2 = new Date(Math.abs(r.nextInt()));
        long time1 = d1.getTime();
        long time2 = d2.getTime();
        if (time1 > time2) {
            System.out.println("time1时间在后");
        } else if (time1 < time2) {
            System.out.println("time1时间在前");
        } else {
            System.out.println("时间一样");
        }
    }

    private static void extracted() {
        //时间原点一年以后得时间
        Date d = new Date(0L);
        long time = d.getTime();
        //在此基础上加一年的时间
        time = time + 1000L * 60 * 60 * 24 * 365;
        //设置时间
        d.setTime(time);
        System.out.println(d);
    }
}
